<?php

namespace Biz\service\brand;

use Biz\model\brand\BrandRecommendedToday;

class BrandRecommendedTodayService
{
    /**
     * 查询今日推荐品牌列表
     * @param array $where
     * @return array|bool
     */
    public static function getBrandRecommendedTodayList(array $where = [])
    {
        $select = [
            'brand_recommended_today.id',
            'brand_recommended_today.brand_id',
            'brand.brand_name',
            'brand.logo',
            'brand.status',
            'brand_recommended_today.addtime',
            'brand_recommended_today.edittime',
        ];
        $where['recommended_today_status'] = BrandRecommendedToday::STATUS_NORMAL;
        $where['ORDER'] = ['recommended_today_sort' => 'ASC', 'addtime' => 'DESC'];

        //dd(BrandRecommendedToday::sqlLogs());
        return BrandRecommendedToday::select(['[><]brand' => ['brand_id' => 'id']], $select, $where);
    }

    /**
     * 获取今日推荐品牌的品牌id
     * @return array
     */
    public static function getBrandRecommendedTodayBrandIdArr(): array
    {
        //获取后台配置的今日推荐前三个品牌
        $where['recommended_today_status'] = BrandRecommendedToday::STATUS_NORMAL;
        $where['ORDER'] = ['recommended_today_sort' => 'ASC', 'addtime' => 'DESC'];
        $brandRecommendedToday = BrandRecommendedToday::selectList($where, ['brand_id']);

        return array_column($brandRecommendedToday, 'brand_id');
    }
}